This is our first program. It will simply light the LED on the bottom bit of port a. It has two statements:

  1. Set the data direction register for port a (TRISA) to make the bottom bit of port a an output (remember that the PICmicro will use a bit as an output if the control bit is 0).

  2. Set the bottom bit of port a high to make the LED come on.

This is a very simple program. You can find out more about the various parts by following the links below:

to find out what the word main is for, click here
to find out what a statement is, click here
to find out about ports in the PIC, click here
to find out about hexadecimal values (0xff for example) and how they are written in C programs, click here

If the code is not visible double-click on the C file in the project workspace to open it up for editing.

Don't worry about the '#pragma' bits in the exercise visable when you open it. These are used to configure the chip, for details have a look here.

When we run this program it simply enables the output pin and then turns it on. If you try this on the VPIC you should see that the bottom bit of port a lights up. Note that our program is not perfect, in that it sits at the very end of the main function. In real life the PIC program would continue down memory doing whatever statements it finds.